san luis revisited

(or... San Luis Revisited, the Milwaukee Solution)

Ross Henderson uploaded one way to solve the problem of ensuring that each word in a
string begins with an upper case character.  Here is another using an external procedure that is
much faster since you are not dependant on 4D's interpreter.

I wrote the enclosed external procedure for an application I am writing.  Forthose of you who are
interested, the code (LightSpeed Cª) is below.  Check out Acius's Tech Note #8 if you are using
LIghtSpeed, because producing externals has a few peculiar twists you will need to know about.

To call the procedure (after it is intalled) just do something like this:

	UpperCaseFirst(vMyString)

Pretty easy, huh?




Note:  I am pretty sure that you may not pass a string field this way.  You would need to put the
contents of the field into the variable, pass the variable to UpperCaseFirst, and return the
variable to the field.  eg.

vMyString := [MyFile]MyField
UpperCaseFirst(vMyString)
[MyFile]MyField := vMyString


Like the man said,  I use the external, It works for me.  If if freaks out on you, well...









/*	 UpperCaseFirst.c
 *	
 *	Gregory James
 *	Tekton Software, Inc.
 *	MCI: TEKTON
 *	CIS: 75106,1773
 *	(414) 962-0334
*/

#include <stdio.h>

pascal main(theString)
char	*theString;
{
	short	i;
	char	*myPtr;
	PtoC(theString);
	for(i=0;i<strlen(theString);i++){
		if(theString[i]>64 && theString[i]<91) theString[i] += 32;
	}
	myPtr=theString;
	if(*myPtr>96 && *myPtr<123) *myPtr -= 32;
	myPtr++;
	while(*myPtr!='\0'){
		if(*myPtr == ' '){
			if(*(myPtr+1)>96 && *(myPtr+1)<123) *(myPtr+1) -= 32;
		}
		myPtr++;
	}
	CtoP(theString);
}
